<?php
    define('fly_id', time());

    $base = dirname(__FILE__);
    $ds = DIRECTORY_SEPARATOR;

    require $base.$ds.'database.php';
    require $base.$ds.'html.php';

    $ref = $_SERVER['QUERY_STRING'];

    if (is_numeric($ref)) {
        $dbo = new DBO();
        $dbo->connect();
        $link = $dbo->getLink($ref);

        if ($link) {
            header('HTTP/1.1 301 Moved Permanently');
            header('Location: '.$link);
            exit;
        } else {
            header("HTTP/1.1 404 Not Found");
            header("Status: 404 Not Found");
            $html = new HTML();
            $html->showPage('404');
        }
    } else {
        switch ($ref) {
            case 'index':
                $html = new HTML();
                $html->showPage('index');
            break;
            default:
            case 'user':
                $html = new HTML();
                $html->showPage('user');
            break;
        }
    }

?>